package com.yunhe.common.model.data;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

import java.util.Objects;

/**
 * 量测对象
 * @author liuronglei
 */
public class Measurement {
    @JsonSerialize(using = ToStringSerializer.class)
    private Long pointNumber;
    private String dtime;
    private Long rtime;
    private Double val;
    private Integer flag;

    public Long getPointNumber() {
        return pointNumber;
    }

    public void setPointNumber(Long pointNumber) {
        this.pointNumber = pointNumber;
    }

    public String getDtime() {
        return dtime;
    }

    public void setDtime(String dtime) {
        this.dtime = dtime;
    }

    public Long getRtime() {
        return rtime;
    }

    public void setRtime(Long rtime) {
        this.rtime = rtime;
    }

    public Double getVal() {
        return val;
    }

    public void setVal(Double val) {
        this.val = val;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Measurement that = (Measurement) o;
        return Objects.equals(pointNumber, that.pointNumber) &&
                Objects.equals(dtime, that.dtime) &&
                Objects.equals(val, that.val);
    }

    @Override
    public int hashCode() {
        return Objects.hash(pointNumber, dtime, val);
    }

    public Integer getFlag() {
        return flag;
    }

    public void setFlag(Integer flag) {
        this.flag = flag;
    }

    public Measurement clone() {
        Measurement newMeasurement = new Measurement();
        newMeasurement.setPointNumber(this.getPointNumber());
        newMeasurement.setDtime(this.getDtime());
        newMeasurement.setRtime(this.getRtime());
        newMeasurement.setVal(this.getVal());
        newMeasurement.setFlag(this.getFlag());
        return newMeasurement;
    }
}
